from flask import Blueprint,request
from flask import jsonify
import pymysql
from unite.comm import get_data
from unite.db import db1
bp_fiction = Blueprint('fiction',__name__)

@bp_fiction.route('/users',methods = ['POST'])
def users():
    data = get_data()
    print(data)
    sql = "select * from users where username = '%s' and password = '%s'" %(data['username'],data['password'])
    db1.find(sql)
    return jsonify({'code':200,'username':data['username']})

@bp_fiction.route('/fiction')
def fiction(): 
    # id = request.args.get('id')
    sql = "select * from coustomer"
    res = db1.findall(sql)
    return jsonify({'code':200,'list':res})
